package ru.susu.algebra;

import java.math.BigInteger;
import java.util.Arrays;

import ru.susu.algebra.gap.parser.GapFileMatrixParser;
import ru.susu.algebra.io.FileUtilities;
import ru.susu.algebra.matrix.BigIntMatrixModUniqueRowsExtractor;
import ru.susu.algebra.matrix.Matrix;
import ru.susu.algebra.matrix.MatrixRowsExtractor;
import ru.susu.algebra.matrix.RemoveNullLinesMatrixTransformer;

/**
 * Анализирует матрицу перехода от базиса центральных идемпотентов к базису классовых сумм
 * A10 1шаг
 * @author akargapolov
 * @since: 03.05.2010
 */
public class BasisClassSumViewer
{
	public static void main(String[] args) throws Exception
	{
		String fileName = "FromGap/A14/MA14.txt";
		System.out.println(FileUtilities.getFileAsString(fileName));
		Matrix matrix = new GapFileMatrixParser().parseFile(fileName);
		matrix = new RemoveNullLinesMatrixTransformer().transformObject(matrix);
		System.out.print(matrix);

		Integer[] numbers = { 3, 4, 7 };
		for (int number : numbers)
		{
			BigIntMatrixModUniqueRowsExtractor extractor = new BigIntMatrixModUniqueRowsExtractor(BigInteger.valueOf(number));
			Integer[] rows = extractor.performOperation(matrix);
			System.out.println("Unique rows mod " + number + ": " + Arrays.toString(rows));
			MatrixRowsExtractor rowsExtractor = new MatrixRowsExtractor(rows);
			matrix = rowsExtractor.transformObject(matrix);
			System.out.println(matrix);
		}
	}

}
